<template>
    <div>
        <button @click="reset">reset</button>
        <button @click="qiehuan(1)">
            1
        </button>
        <button @click="qiehuan(2)">
            2
        </button>
        <keep-alive>
            <A v-model="params" v-if="visible==1"></A>
        </keep-alive>
        <keep-alive>
            <B v-model="params" v-if="visible==2"></B>
        </keep-alive>
    
    </div>
</template>
<script>
    import A from './components/A'
    import B from './components/B'
    export default {
        components:{A,B},
        data(){
            return{
                visible:1,
                params:1
            }
        },
        methods:{
            qiehuan(index){
                this.visible=index
            },
            reset(){
                this.params++
            }
        }
    }

</script>